#include<iostream>
using namespace std;
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>

class Solution {
public:
    vector<string> permutation(string s) {
        vector<string> ret;
        char* str = (char*)s.data();
        this->process(str,0,s.length(),ret);
        cout << ret.size() << endl;
        this->print(ret);
        return ret;
    }
    void process(char str[],int i,int len,vector<string>& ret)
    {
        if(i == len) {
            string vret = str;
            ret.push_back(vret);
            return;
        }
        bool visit[26];
        memset(visit,false,sizeof(bool)*26);
        for(int k=i; k<len; k++) {
            if(!visit[str[k]-'a']) {
                visit[str[k]-'a'] = true;
                swap(str[i],str[k]);
                this->process(str,i+1,len,ret);
                swap(str[i],str[k]);
            }
        }
    }
    void print(const vector<string>& ret) {
        for(auto it = ret.begin(); it != ret.end(); it++) {
            cout << *it << endl;
        }
    }

};

int main() {
    Solution().permutation("abc");
    return 0;
}